﻿using System;
using System.IO;

class TextFileWithNumbers
{
    static void Main()
    {
        //Exercise 3.
        //Write a program that reads a text file and inserts line numbers in front of each of its lines. 
        //The result should be written to another text file.

        string fileName = @"C:\Users\Toni\Desktop\Test File.txt";
        StreamReader reader = new StreamReader(fileName);

        string fileNameFinal = "File.txt";
        StreamWriter streamWriter = new StreamWriter(fileNameFinal);

        string final = string.Empty;

        using (reader)
        {
            final = reader.ReadLine();
            int lineNumber = 0;            
            while (final != null)
            {
                lineNumber++;
                streamWriter.WriteLine("Line {0}:  {1}", lineNumber, final);                
                final = reader.ReadLine();
            }
        }
        
        streamWriter.Close();
        
        Console.WriteLine("File is written!");
    }
}

